package my.jwds.p504;

public class ConvertToBase7 {
    public static void main(String[] args) {
        ConvertToBase7 obj = new ConvertToBase7();

        System.out.println(obj.convertToBase7(-7));
    }



    public String convertToBase7(int num) {
        if (num == 0)return "0";
        StringBuilder sb = new StringBuilder();
        String fh = (num < 0 ? "-":"");
        num = Math.abs(num);
        while(num != 0){
            sb.append(num%7);
            num/=7;
        }
        return fh + sb.reverse().toString();
    }
}
